<?php
class MD_Lang
{
	public static function getAll()
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM lang ");
    	return $content;
	}
	
	public static function getEnabledLangs()
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM lang where enabled = 1");
    	return $content;
	}
	
	public static function getLangById($id)
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM lang where id = '$id' ");
    	return $content[0];
	} 

		public static function getLangByKey($key)
	{
		$content = TN_Db::getInstance()->fetchAll("SELECT * FROM lang where prefix2 = '$key' ");
    	return $content[0];
	} 
	
	public static function add( $name, $prefix2, $prefix3, $image, $enabled )
	{
		TN_Db::getInstance()->insert('lang', array('name'=> $name, 'prefix2' => $prefix2,'prefix3' => $prefix3 , 'image' => $image, 'enabled' => $enabled));
	}
	
	public static function update($id, $name, $prefix2, $prefix3, $image, $enabled )
	{
		TN_Db::getInstance()->update('lang', array('name'=> $name, 'prefix2' => $prefix2,'prefix3' => $prefix3 , 'image' => $image, 'enabled' => $enabled), "id = '$id' ");
	}
		
	public static function delete ($id )
	{
		TN_Db::getInstance()->delete('lang', "id = '$id' ");
	}
 	public static function lastId()
    {
    	return TN_Db::getInstance()->lastInsertId('lang');
    }
    
    public static function setImage($id, $img)
    {
    	TN_Db::getInstance()->update('lang', array('image' => $img), "id = '$id' ");
    }
}
?>